﻿namespace System.Data.Entity.ModelConfiguration.Conventions
{
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.ModelConfiguration.Configuration;

    /// <summary>
    /// Convention to process instances of <see cref="FullTextIndexedTableAttribute" /> found on types in the model.
    /// </summary>
    public class FullTextIndexedTableAttributeConvention :
        TypeAttributeConfigurationConvention<FullTextIndexedTableAttribute>
    {
        /// <inheritdoc />
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods")]
        public override void Apply(ConventionTypeConfiguration configuration, FullTextIndexedTableAttribute attribute)
        {
            configuration.HasTableAnnotation
                (
                FullTextIndexedTableAnnotation.AnnotationName,
                new FullTextIndexedTableAnnotation(new FullTextIndexedTableAttribute(configuration.ClrType.Name))
                );
        }
    }
}
